﻿@model CMSApplication.Areas.Administration.Models.CustomerModel
<script>
    jQuery(document).ready(function ($) {
        $("form[data-id='add-customer']").submit(function (e) {
            $frm = $(this);
            Ajax({
                url: $frm.attr("action"),
                type: "post",
                data: $frm.serialize(),
                ExecSuccess: function (result) {
                    if (result.dataServer.Id > 0) {
                        $.pnotify({
                            title: "Thông báo",
                            text: "Tạo mới khách hàng thành công",
                            type: "info",
                            opacity: .8
                        });
                        var item = {
                            Id: result.dataServer.Id,
                            Name: $frm[0].Name.value,
                            Phone: $frm[0].Phone.value,
                            Addr: $frm[0].Addr.value
                        };
                        UpdCustomerInfo(item);
                        $.fancybox.close();
                    } else {
                        $.pnotify({
                            title: "Lỗi",
                            text: "Tạo mới khách hàng không thành công",
                            type: "error",
                            opacity: .8
                        });
                    }
                }
            });
            return false;
        });
    });
</script>
<div class="row-fluid">
    <div class="span12">
        <div class="head">
            <h4>Thêm mới khách hàng</h4>
            <div class="clear"></div>
        </div>
        <div class="block-fluid">
            @using (Html.BeginForm("Customer_Popup_Add", "Work", FormMethod.Post, new { enctype = "multipart/form-data", @id = "validation", @data_id = "add-customer" }))
            {
                <div class="warning-area"></div>
                @Html.HiddenFor(m => m.Id)
                @Html.HiddenFor(m => m.Active)
                <div class="row-form">
                    <div class="span2">Tên</div>
                    <div class="span10">@Html.TextBoxFor(x => x.Name, new { })</div>
                    <div class="clear"></div>
                </div>
                <div class="row-form">
                    <div class="span2">Loại</div>
                    <div class="span10">@Html.DropDownListFor(x => x.Type, Model.SLType)</div>
                    <div class="clear"></div>
                </div>
                <div class="row-form">
                    <div class="span2">Địa chỉ</div>
                    <div class="span10">@Html.TextBoxFor(x => x.Addr, new { })</div>
                    <div class="clear"></div>
                </div>
                <div class="row-form">
                    <div class="span2">Điện thoại</div>
                    <div class="span10">@Html.TextBoxFor(x => x.Phone, new { })</div>
                    <div class="clear"></div>
                </div>
                <div class="row-form">
                    <div class="span2"></div>
                    <div class="span10">
                        <input type="submit" class="btn btn-info btnSubmit" value="Lưu lại" />
                    </div>
                    <div class="clear"></div>
                </div>
            }
        </div>
    </div>
</div>
